---
description: "Reference for Nitric's Node.js library - Retrieves the value from a version of a secret."
---

# Node.js - secret.version.access()

<Note>
  This is reference documentation for the Nitric Node.js SDK. To learn about
  Secrets in Nitric start with the [Secrets docs](/secrets).
</Note>

Retrieves the value from a version of a secret.

```javascript
import { secret } from '@nitric/sdk'

const keyRef = secret('apiKey').allow('access')

const keyValue = await keyRef.latest().access()

keyValue.asString()
```

## Examples

### Access the latest version of a secret

```javascript
import { secret } from '@nitric/sdk'

const keyRef = secret('apiKey').allow('access')

const keyValue = await keyRef.latest().access()

keyValue.asString()
```

### Access a specific version of a secret

```javascript
import { secret } from '@nitric/sdk'

const keyRef = secret('apiKey').allow('access')

const keyValue = await keyRef.version('the-version-id').access()

keyValue.asString()
```
